#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;
const int L = 1e8 + 1;

int x[2][N], y[2][N], R, C, n, stk[N], cnt;
veg t;

int id(int x, int y) {
	if(x == 0) return y;
	if(y == C) return L + x;
	if(x == R) return L + L + C - y;
	if(y == 0) return L + L + L + R - x;
	return 0;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	R = in, C = in, n = in;
	rep(i, 1, n) x[0][i] = in, y[0][i] = in, x[1][i] = in, y[1][i] = in;
	rep(i, 1, n) {
		bool fl = true;
		fl &= x[0][i] == 0 || x[0][i] == R || y[0][i] == 0 || y[0][i] == C ;
		fl &= x[1][i] == 0 || x[1][i] == R || y[1][i] == 0 || y[1][i] == C;
		if(!fl) continue;
		int id1 = id(x[0][i], y[0][i]), id2 = id(x[1][i], y[1][i]);
		if(id1 > id2) swap(id1, id2); //cerr << id1 << " " << id2 << " " << i << endl;
		t.pb({ id1, i }), t.pb({ id2, -i });
	}
	sort(t.begin(), t.end());
	for(auto d : t)
		if(d.se < 0) {
			if(cnt == 0 || stk[cnt] != -d.se) return /*cerr << d.se << " " << stk[cnt] << endl,*/ puts("NO"), 0;
			cnt--;
		} else stk[++cnt] = d.se;
	puts("YES");
	return 0;
}
